// 验证基于向量数据的文本匹配问题

import { OllamaEmbeddings } from "@langchain/community/embeddings/ollama";
import { Chroma } from "@langchain/community/vectorstores/chroma";

const embeddings = new OllamaEmbeddings({
  model: "nomic-embed-text", // default value
  baseUrl: "http://117.72.38.226:11434", // default value
  requestOptions: {
    // useMMap: true,
    numThread: 6,
    // numGpu: 1,
  },
});

const documents = [
    "今天天气糟糕透了",
    "今天阳光明媚，我很喜欢", //正向
    "今天天气很好", // 正向
    "今天天气不错", // 正向
    "今天天气很差", // 负面
    "今天我吃了两个鸡蛋，天气很好，我要出去玩", 
    "鸡蛋是最好的早餐",
    "有些人早餐喜欢吃热干面"
];

const vectorStore = await Chroma.fromTexts(
    documents,
    [{ id: 2 }, { id: 1 }, { id: 3 }],
    embeddings,
    {
      collectionName: "test-hcy-3", // 
      url: "http://117.72.38.226:8000",
    }
  );
const response = await vectorStore.similaritySearch("今天天气还可以", 2);
console.log(response)

